home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr26 / netprog.zip / NETPROG.TAR / net / sppcli.c < prev    next >
C/C++ Source or Header  |  1989-12-17  |  858b  |  46 lines

  1. /*
  2.  * Example of client using SPP protocol.
  3.  */
  4.  
  5. #include    "xns.h"
  6.  
  7. main(argc, argv)
  8. int    argc;
  9. char    *argv[];
  10. {
  11.     int            sockfd;
  12.     struct sockaddr_ns    serv_addr;
  13.  
  14.     pname = argv[0];
  15.  
  16.     /*
  17.      * Fill in the structure "serv_addr" with the XNS address of the
  18.      * server that we want to connect with.
  19.      */
  20.  
  21.     bzero((char *) &serv_addr, sizeof(serv_addr));
  22.     serv_addr.sns_family = AF_NS;
  23.     serv_addr.sns_addr   = ns_addr(SPP_SERV_ADDR);
  24.                 /* stores net-ID, host-ID and port */
  25.  
  26.     /*
  27.      * Open a SPP socket (an XNS stream socket).
  28.      */
  29.  
  30.     if ( (sockfd = socket(AF_NS, SOCK_STREAM, 0)) < 0)
  31.         err_sys("client: can't open stream socket");
  32.  
  33.     /*
  34.      * Connect to the server.
  35.      */
  36.  
  37.     if (connect(sockfd, (struct sockaddr *) &serv_addr,
  38.                             sizeof(serv_addr)) < 0)
  39.         err_sys("client: can't connect to server");
  40.  
  41.     str_cli(stdin, sockfd);        /* do it all */
  42.  
  43.     close(sockfd);
  44.     exit(0);
  45. }
  46.